gdkdisplay.c: Fix builds without EGL
authorChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 7 Oct 2021 14:59:37 +0000 (22:59 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 8 Nov 2021 07:25:24 +0000 (15:25 +0800)
We need to ensure that gdk_display_get_egl_display() is available even if EGL
is not enabled in the build, so that things will continue to link and work.

For builds without EGL, just return NULL.

gdk/gdkdisplay.c

index c7993d436ae1fbad10fa161112adbe7b8290c0fd..dddc8b206025d9219592af412a4b6c1973b5cf1e 100644 (file)
@@ -1438,31 +1438,6 @@ describe_egl_config (EGLDisplay egl_display,
 }
 #endif
 
-/*<private>
- * gdk_display_get_egl_display:
- * @self: a display
- *
- * Retrieves the EGL display connection object for the given GDK display.
- *
- * This function returns `NULL` if GL is not supported or GDK is using
- * a different OpenGL framework than EGL.
- *
- * Returns: (nullable): the EGL display object
- */
-gpointer
-gdk_display_get_egl_display (GdkDisplay *self)
-{
-  GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
-
-  g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
-
-  if (!priv->egl_display &&
-      !gdk_display_prepare_gl (self, NULL))
-    return NULL;
-
-  return priv->egl_display;
-}
-
 gpointer
 gdk_display_get_egl_config (GdkDisplay *self)
 {
@@ -1789,6 +1764,35 @@ gdk_display_init_egl (GdkDisplay  *self,
 }
 #endif
 
+/*<private>
+ * gdk_display_get_egl_display:
+ * @self: a display
+ *
+ * Retrieves the EGL display connection object for the given GDK display.
+ *
+ * This function returns `NULL` if GL is not supported or GDK is using
+ * a different OpenGL framework than EGL.
+ *
+ * Returns: (nullable): the EGL display object
+ */
+gpointer
+gdk_display_get_egl_display (GdkDisplay *self)
+{
+  GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
+
+  g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
+
+#ifdef HAVE_EGL
+  if (!priv->egl_display &&
+      !gdk_display_prepare_gl (self, NULL))
+    return NULL;
+
+  return priv->egl_display;
+#else
+  return NULL;
+#endif
+}
+
 GdkDebugFlags
 gdk_display_get_debug_flags (GdkDisplay *display)
 {